import http from '../util/http';

// 获取用户名单
const getUserList = data => http.getData(data, '/api/users');

// 获取用户详情
const getUserDetail = ({ userId }) => http.getData({}, `/api/users/${userId}`);

// 注册用户
const addUser = data => http.postData(data, '/api/users/create');

// 修改用户资料
const editUser = data => http.postData(data, `/api/users/${data.id}/edit`);

// 重置密码
const resetPassword = ({ id }) => http.postData({}, `/api/users/${id}/reset`);

// 获取公众号列表
const getPublicAccounts = data => http.getData(data, '/api/publicAccounts');

// 改变用户状态
const changeStatus = ({ id, isActive }) => http.postData({ isActive }, `/api/users/${id}/change-status`);

// 账号管理根据姓名和用户名搜索
const getUserSearch = ({ nameType, name }) => http.getData({}, `/api/users/${nameType}/${name}`);

export default {
  getUserList,
  getUserDetail,
  addUser,
  editUser,
  resetPassword,
  getPublicAccounts,
  changeStatus,
  getUserSearch,
};
